package com.erp.erp_servers.warehouse.imp;

import com.erp.erp_dao.warehouse.IPlanInstoreDao;
import com.erp.erp_entitys.warehouse.entity.PlanInstoreEntity;
import com.erp.erp_entitys.warehouse.req.PlanInStoreListReq;
import com.erp.erp_entitys.warehouse.req.PlanInStoreStatistics1Req;
import com.erp.erp_entitys.warehouse.rsp.PlanInStorePageLisRsp;
import com.erp.erp_entitys.warehouse.rsp.PlanInStoreStatistics1Rsp;
import com.erp.erp_servers.warehouse.IPlanInstoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName : PlanInstoreServiceImp
 * @Description : 备货入库实现类
 * @Author : lst
 * @Date: 2020-07-01 18:16
 */
@Service
public class PlanInstoreServiceImp implements IPlanInstoreService {

    /**
     * 备货入库接口
     */
    private final IPlanInstoreDao planInStoreDao;

    @Autowired
    public PlanInstoreServiceImp(IPlanInstoreDao planInStoreDao) {
        this.planInStoreDao = planInStoreDao;
    }


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlanInstoreEntity queryById(Integer id) {
        return planInStoreDao.queryById(id);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param planInstore 实例对象
     * @return 对象列表
     */
    @Override
    public List<PlanInstoreEntity> queryAll(PlanInstoreEntity planInstore) {
        return planInStoreDao.queryAll(planInstore);
    }

    /**
     * 获取备货入库信息
     * @param req 查询条件
     * @return 查询结果
     */
    @Override
    public List<PlanInStorePageLisRsp> getListByPage(PlanInStoreListReq req) {
        return planInStoreDao.getListByPage(req);
    }

    /**
     * 新增数据
     *
     * @param planInstore 实例对象
     * @return 影响行数
     */
    @Override
    public int insert(PlanInstoreEntity planInstore) {
        return planInStoreDao.insert(planInstore);
    }

    /**
     * 修改数据
     *
     * @param planInstore 实例对象
     * @return 影响行数
     */
    @Override
    public int update(PlanInstoreEntity planInstore) {
        return planInStoreDao.update(planInstore);
    }

    @Override
    public List<PlanInStoreStatistics1Rsp> planInStoreStatistics1ListByPage(PlanInStoreStatistics1Req req) {
        if (req.getSource().equals("purchase")){
            return planInStoreDao.planInStoreStatistics1ListByPage(req);
        }else {
            return planInStoreDao.planInStoreStatisticsExportListByPage(req);
        }
    }
}
